package org.hy.commons.web.example.request.dispatcher;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TestRequestServlet extends HttpServlet {

	Logger logger = LoggerFactory.getLogger(getClass());

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		logger.info(request.toString());
		//获得相应的信息
		Object root = request.getAttribute("root");
		//System.out.println(root);
		
		
		//输出内容
		logger.info("【" +
				getClass().getSimpleName()+
				"】收到【RequestDispatcherServlet】的转发");
		logger.info("【" +
				getClass().getSimpleName()+
				"】转发调用中....");
		logger.info("【" +
				getClass().getSimpleName()+
				"】收到【RequestDispatcherServlet】的转发的参数【root='" +
				request.getAttribute("root")+"'】");
		PrintWriter out = response.getWriter();  //必须值调用的servlet使用的流相同

		out.println("【" +
				getClass().getSimpleName()+
				"】以下内容可以在浏览器中显示");
		out.println("【" +
				getClass().getSimpleName()+
				"】转发调用中...."+"页面转发调用中....<br/>");
		
		
		
		
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

	}

}
